#!/bin/sh
# Maciej Wieslaw Trzcinski


ls m3 | grep '\.alice$' | while read line
do
	basename=`basename $line .alice`
	./compiler --P --file $line
	if [ ! $? -eq 0 ]
	then
		find "0" "$basename parsing failed!!"		
	fi

	diff -B -q temp.output "$basename.compilation"

	$basename > temp.output >&2 "$basename.input"

	diff -B -q temp.output "$basename.output"
	if [ ! $? -eq 0 ]
	then
		echo "FAIL: Difference found in $basename!!!" 
	else
		echo "PASS: $basename"
	fi

	rm $basename temp.output
done

